package camel.corp.universalcopy;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.KeyCharacterMap;
import android.view.ViewConfiguration;
import android.widget.Toast;
import com.camel.corp.universalcopy.MaterialSwitchPreference;
import com.camel.corp.universalcopy.T;
import com.camel.corp.universalcopy.U;
import com.camel.corp.universalcopy.V;
import com.camel.corp.universalcopy.W;
import com.camel.corp.universalcopy.X;
import com.camel.corp.universalcopy.Y;
import com.camel.corp.universalcopy.Z;
import com.camel.corp.universalcopy.a.k;
import com.camel.corp.universalcopy.aa;
import com.camel.corp.universalcopy.b.g;
import com.camel.corp.universalcopy.ba;
import com.camel.corp.universalcopy.ca;
import com.camel.corp.universalcopy.da;
import com.camel.corp.universalcopy.ea;
import com.camel.corp.universalcopy.fa;
import com.camel.corp.universalcopy.ga;
import com.camel.corp.universalcopy.ma;
import java.util.LinkedHashMap;

public class ga extends PreferenceFragment implements k.a {
  private Boolean a;
  
  private void a(boolean paramBoolean1, boolean paramBoolean2) {
    Preference preference = getPreferenceScreen().findPreference("linked_pref");
    if (paramBoolean1) {
      preference.setSummary(2131755168);
      b(paramBoolean2);
      return;
    } 
    preference.setSummary(2131755176);
    b(false);
  }
  
  private void b(boolean paramBoolean) {
    String str;
    if (paramBoolean) {
      str = "UNIVERSAL_COPY_ACTIVATE";
    } else {
      str = "UNIVERSAL_COPY_DISABLE";
    } 
    Intent intent = new Intent(str);
    getActivity().sendBroadcast(intent);
  }
  
  public void a(boolean paramBoolean) {
    if (paramBoolean) {
      Preference preference = getPreferenceScreen().findPreference("uc_plus_pref");
      if (preference != null)
        getPreferenceScreen().removePreference(preference); 
    } 
  }
  
  public boolean a() {
    Boolean bool = this.a;
    if (bool != null)
      return bool.booleanValue(); 
    int i = Build.VERSION.SDK_INT;
    int j = 1;
    byte b = 1;
    if (i >= 17) {
      Display display = getActivity().getWindowManager().getDefaultDisplay();
      DisplayMetrics displayMetrics = new DisplayMetrics();
      display.getRealMetrics(displayMetrics);
      i = displayMetrics.heightPixels;
      int k = displayMetrics.widthPixels;
      displayMetrics = new DisplayMetrics();
      display.getMetrics(displayMetrics);
      int m = displayMetrics.heightPixels;
      j = b;
      if (k - displayMetrics.widthPixels <= 0)
        if (i - m > 0) {
          j = b;
        } else {
          j = 0;
        }  
      this.a = Boolean.valueOf(j);
    } else {
      boolean bool1;
      boolean bool2 = ViewConfiguration.get(getActivity()).hasPermanentMenuKey();
      boolean bool3 = KeyCharacterMap.deviceHasKey(4);
      if (bool2 || bool3)
        bool1 = false; 
      this.a = Boolean.valueOf(bool1);
    } 
    return this.a.booleanValue();
  }
  
  public Boolean b() { return (Build.VERSION.SDK_INT >= 23) ? Boolean.valueOf(((PowerManager)getActivity().getSystemService("power")).isIgnoringBatteryOptimizations(getActivity().getPackageName())) : null; }
  
  public boolean c() { return ((k)getActivity()).o(); }
  
  public void onCreate(Bundle paramBundle) {
    boolean bool2;
    boolean bool1;
    super.onCreate(paramBundle);
    addPreferencesFromResource(2131951618);
    int i = getResources().getColor(2131099690);
    getPreferenceScreen().findPreference("service_active").setOnPreferenceChangeListener(new X(this));
    Boolean bool3 = b();
    paramBundle = getArguments();
    Boolean bool4 = Boolean.valueOf(false);
    if (paramBundle.getBoolean("accessibility_was_reset", false) && Boolean.FALSE.equals(bool3)) {
      Preference preference1 = new Preference(getActivity());
      preference1.setKey("uc_warning_whitelist_app");
      preference1.setSummary(ma.a(getString(2131755044), getResources().getColor(2131099858)));
      preference1.setOnPreferenceClickListener(new Y(this));
      getPreferenceScreen().addPreference(preference1);
    } 
    if (!c()) {
      Preference preference1 = new Preference(getActivity());
      preference1.setKey("uc_plus_pref");
      preference1.setTitle(ma.a(getString(2131755215), "PLUS", i));
      preference1.setSummary(2131755214);
      preference1.setOnPreferenceClickListener(new Z(this));
      getPreferenceScreen().addPreference(preference1);
    } 
    PreferenceCategory preferenceCategory2 = new PreferenceCategory(getActivity());
    preferenceCategory2.setTitle(2131755212);
    getPreferenceScreen().addPreference(preferenceCategory2);
    MaterialSwitchPreference materialSwitchPreference1 = new MaterialSwitchPreference(getActivity(), null);
    materialSwitchPreference1.setTitle(2131755213);
    materialSwitchPreference1.setSwitchTextOn(2131755041);
    materialSwitchPreference1.setSwitchTextOff(2131755079);
    materialSwitchPreference1.setDefaultValue(Boolean.valueOf(true));
    materialSwitchPreference1.setKey("notification_active");
    materialSwitchPreference1.setOnPreferenceChangeListener(new aa(this));
    preferenceCategory2.addPreference(materialSwitchPreference1);
    materialSwitchPreference1.setDependency("service_active");
    ListPreference listPreference = new ListPreference(getActivity());
    listPreference.setKey("long_click_button");
    listPreference.setTitle(2131755208);
    if (Build.VERSION.SDK_INT >= 18) {
      bool2 = true;
    } else {
      bool2 = false;
    } 
    if (Build.VERSION.SDK_INT >= 21) {
      bool1 = true;
    } else {
      bool1 = false;
    } 
    listPreference.setEnabled(bool2);
    if (bool2) {
      String str3;
      String str1;
      LinkedHashMap linkedHashMap = new LinkedHashMap();
      linkedHashMap.put(getString(2131755206), "NONE");
      String str4 = ma.a(getActivity(), "accessibility_back", "com.android.systemui", "");
      String str5 = ma.a(getActivity(), "accessibility_home", "com.android.systemui", "");
      String str6 = ma.a(getActivity(), "accessibility_recent", "com.android.systemui", "");
      if (a()) {
        if (bool1) {
          str3 = str5;
          str2 = str6;
          str1 = str4;
        } else {
          str1 = "";
          str2 = str1;
          str3 = str2;
        } 
      } else {
        StringBuilder stringBuilder1 = new StringBuilder();
        stringBuilder1.append("");
        stringBuilder1.append(4);
        str1 = stringBuilder1.toString();
        StringBuilder stringBuilder2 = new StringBuilder();
        stringBuilder2.append("");
        stringBuilder2.append(3);
        str3 = stringBuilder2.toString();
        stringBuilder2 = new StringBuilder();
        stringBuilder2.append("");
        stringBuilder2.append(187);
        str2 = stringBuilder2.toString();
      } 
      if (!"".equals(str1))
        linkedHashMap.put(getString(2131755205), str1); 
      if (!"".equals(str2))
        linkedHashMap.put(getString(2131755209), str2); 
      if (!"".equals(str3))
        linkedHashMap.put(getString(2131755207), str3); 
      linkedHashMap.put(getString(2131755211), "24");
      linkedHashMap.put(getString(2131755210), "25");
      listPreference.setEntries((CharSequence[])linkedHashMap.keySet().toArray(new String[0]));
      listPreference.setEntryValues((CharSequence[])linkedHashMap.values().toArray(new String[0]));
      listPreference.setDefaultValue("NONE");
      ListPreference listPreference1 = listPreference;
      listPreference1.setOnPreferenceChangeListener(new ba(this, str5, str4, str6, listPreference));
      String str2 = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("long_click_button", "NONE");
      listPreference1.getOnPreferenceChangeListener().onPreferenceChange(listPreference1, str2);
    } else {
      listPreference.setSummary(2131755201);
    } 
    preferenceCategory2.addPreference(listPreference);
    listPreference.setDependency("service_active");
    PreferenceCategory preferenceCategory1 = new PreferenceCategory(getActivity());
    preferenceCategory1.setTitle(2131755179);
    getPreferenceScreen().addPreference(preferenceCategory1);
    MaterialSwitchPreference materialSwitchPreference2 = new MaterialSwitchPreference(getActivity(), null);
    materialSwitchPreference2.setDefaultValue(bool4);
    materialSwitchPreference2.setTitle(ma.a(getString(2131755150), "PLUS", i));
    materialSwitchPreference2.setEnabled(bool1);
    materialSwitchPreference2.setKey("ocr_mode_active");
    if (bool1) {
      materialSwitchPreference2.setSummary(2131755149);
      materialSwitchPreference2.setOnPreferenceChangeListener(new ca(this));
    } else {
      materialSwitchPreference2.setSummary(2131755201);
    } 
    preferenceCategory1.addPreference(materialSwitchPreference2);
    materialSwitchPreference2 = new MaterialSwitchPreference(getActivity(), null);
    materialSwitchPreference2.setDefaultValue(Boolean.valueOf(true));
    materialSwitchPreference2.setSummary(2131755185);
    materialSwitchPreference2.setTitle(2131755186);
    materialSwitchPreference2.setKey("preview_copy_zones");
    preferenceCategory1.addPreference(materialSwitchPreference2);
    materialSwitchPreference2 = new MaterialSwitchPreference(getActivity(), null);
    materialSwitchPreference2.setDefaultValue(bool4);
    materialSwitchPreference2.setSummary(2131755174);
    materialSwitchPreference2.setTitle(2131755175);
    materialSwitchPreference2.setKey("full_screen_auto");
    preferenceCategory1.addPreference(materialSwitchPreference2);
    materialSwitchPreference2 = new MaterialSwitchPreference(getActivity(), null);
    materialSwitchPreference2.setDefaultValue(bool4);
    materialSwitchPreference2.setSummary(2131755077);
    materialSwitchPreference2.setTitle(2131755078);
    materialSwitchPreference2.setKey("disable_animation");
    preferenceCategory1.addPreference(materialSwitchPreference2);
    if (bool3 != null) {
      materialSwitchPreference2 = new MaterialSwitchPreference(getActivity(), null);
      materialSwitchPreference2.setDefaultValue(bool4);
      materialSwitchPreference2.setChecked(bool3.booleanValue());
      materialSwitchPreference2.setKey("uc_whitelist_app");
      materialSwitchPreference2.setTitle(ma.a(getString(2131755184), "NEW", i));
      materialSwitchPreference2.setSummary(2131755183);
      materialSwitchPreference2.setOnPreferenceChangeListener(new da(this, bool3));
      preferenceCategory1.addPreference(materialSwitchPreference2);
    } 
    preferenceCategory1.setDependency("service_active");
    preferenceCategory1 = new PreferenceCategory(getActivity());
    preferenceCategory1.setTitle(ma.a(getString(2131755182), "NEW", i));
    getPreferenceScreen().addPreference(preferenceCategory1);
    g g = new g(getActivity());
    g.setDefaultValue("copy");
    g.setKey("shortcut_doubletap");
    g.setTitle(2131755173);
    g.setSummary(2131755172);
    preferenceCategory1.addPreference(g);
    g = new g(getActivity());
    g.setDefaultValue("edit");
    g.setKey("shortcut_longpress");
    g.setTitle(2131755178);
    g.setSummary(2131755177);
    preferenceCategory1.addPreference(g);
    preferenceCategory1 = new PreferenceCategory(getActivity());
    preferenceCategory1.setTitle(2131755169);
    getPreferenceScreen().addPreference(preferenceCategory1);
    Preference preference = new Preference(getActivity());
    preference.setTitle(2131755085);
    preference.setSummary(2131755080);
    preference.setOnPreferenceClickListener(new ea(this));
    preferenceCategory1.addPreference(preference);
    preference = new Preference(getActivity());
    preference.setTitle(2131755181);
    preference.setSummary(2131755180);
    preference.setOnPreferenceClickListener(new fa(this));
    preferenceCategory1.addPreference(preference);
    preference = new Preference(getActivity());
    preference.setTitle(2131755114);
    preference.setSummary(2131755095);
    preference.setOnPreferenceClickListener(new T(this));
    preferenceCategory1.addPreference(preference);
    preference = new Preference(getActivity());
    preference.setTitle(2131755088);
    preference.setSummary(2131755087);
    preference.setOnPreferenceClickListener(new U(this));
    preferenceCategory1.addPreference(preference);
    preference = new Preference(getActivity());
    preference.setTitle(2131755162);
    preference.setOnPreferenceClickListener(new V(this));
    preferenceCategory1.addPreference(preference);
    preference = new Preference(getActivity());
    preference.setTitle(2131755167);
    try {
      PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append(getResources().getString(2131755166));
      stringBuilder.append(" ");
      stringBuilder.append(packageInfo.versionName);
      preference.setSummary(stringBuilder.toString());
    } catch (android.content.pm.PackageManager.NameNotFoundException nameNotFoundException) {}
    preference.setOnPreferenceClickListener(new W(this));
    preferenceCategory1.addPreference(preference);
  }
  
  public void onResume() {
    super.onResume();
    Preference preference2 = getPreferenceScreen().findPreference("uc_warning_whitelist_app");
    MaterialSwitchPreference materialSwitchPreference = (MaterialSwitchPreference)getPreferenceScreen().findPreference("service_active");
    Preference preference1 = preference2;
    if (materialSwitchPreference != null) {
      boolean bool1;
      SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(materialSwitchPreference.getContext());
      boolean bool2 = sharedPreferences.getBoolean("service_active", false);
      boolean bool3 = sharedPreferences.getBoolean("accessibility_active", false);
      boolean bool4 = sharedPreferences.getBoolean("notification_active", true);
      if (bool2 && bool3) {
        bool1 = true;
      } else {
        bool1 = false;
      } 
      materialSwitchPreference.setChecked(bool1);
      if (bool2 && bool3) {
        bool1 = true;
      } else {
        bool1 = false;
      } 
      a(bool1, bool4);
      preference1 = preference2;
      if (preference2 != null) {
        preference1 = preference2;
        if (bool2) {
          preference1 = preference2;
          if (bool3) {
            getPreferenceScreen().removePreference(preference2);
            preference1 = null;
          } 
        } 
      } 
    } 
    Boolean bool = b();
    if (preference1 != null && Boolean.TRUE.equals(bool))
      if (getArguments().getBoolean("accessibility_was_reset", false)) {
        Toast.makeText(getActivity(), 2131755216, 1).show();
        preference1.setSummary(ma.a(getString(2131755045), getResources().getColor(2131099858)));
      } else {
        getPreferenceScreen().removePreference(preference1);
      }  
    preference1 = getPreferenceScreen().findPreference("uc_whitelist_app");
    if (preference1 != null && bool != null)
      ((MaterialSwitchPreference)preference1).setChecked(bool.booleanValue()); 
  }
}


/* Location:              D:\Users\alienware\AndroidStudioProjects\Lazero\sample\sampler\classes-dex2jar\com\camel.jar!\camel\cor\\universalcopy\ga.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.0.7
 */